﻿Public Class RGV

    Private carName As String
    Public Property CarName1 As String
        Get
            Return carName
        End Get
        Set(value As String)
            carName = value
            lblCarName.Text = value
        End Set
    End Property



    Private Sub RGV_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not HslCommunication.Authorization.SetAuthorizationCode("e3e27344-1a9f-4d8b-b4fc-da5cae4b99bf") Then

        End If
        If Not HslControls.Authorization.SetAuthorizationCode("ce5ade06-6f14-4b0d-b9c2-0d625664dc3f") Then

        End If

    End Sub
    Public Sub setStatus(_dr As DataRow)
        Try
            If IsNothing(_dr) Then Exit Sub

            Dim boolCommunication As Boolean
            If DBNULLtoBlank(_dr("Communication")) = "" Then
                boolCommunication = False
            Else
                boolCommunication = _dr("Communication")
            End If

            If boolCommunication = True Then
                lblCarName.BackColor = Color.Lime
                lblCarName.ForeColor = Color.Black

                Dim boolDoorOpen As Boolean
                If DBNULLtoBlank(_dr("DoorOpen")) = "" Then
                    boolDoorOpen = False
                Else
                    boolDoorOpen = _dr("DoorOpen")
                End If

                If boolDoorOpen = False Then
                    pnlDoor.BackColor = Color.White
                Else
                    pnlDoor.BackColor = Color.OrangeRed
                End If

                lanStop.Visible = IIf(DBNULLtoBlank(_dr("stop")) = "", False, _dr("stop"))

                If DBNULLtoZero(_dr("_1_2_UP")) = 1 Then
                    pnlUpDn12.Visible = True
                Else
                    pnlUpDn12.Visible = False
                End If
                If DBNULLtoZero(_dr("_1_1_UP")) = 1 Then
                    pnlUpDn11.Visible = True
                Else
                    pnlUpDn11.Visible = False
                End If
                If DBNULLtoZero(_dr("_2_2_UP")) = 1 Then
                    pnlUpDn22.Visible = True
                Else
                    pnlUpDn22.Visible = False
                End If
                If DBNULLtoZero(_dr("_2_1_UP")) = 1 Then
                    pnlUpDn21.Visible = True
                Else
                    pnlUpDn21.Visible = False
                End If

                If DBNULLtoZero(_dr("out1")) = 1 Then
                    pnl11.BackColor = Color.Black
                Else
                    pnl11.BackColor = Color.White
                End If
                If DBNULLtoZero(_dr("in1")) = 1 Then
                    pnl12.BackColor = Color.Black
                Else
                    pnl12.BackColor = Color.White
                End If
                If DBNULLtoZero(_dr("out2")) = 1 Then
                    pnl21.BackColor = Color.Black
                Else
                    pnl21.BackColor = Color.White
                End If
                If DBNULLtoZero(_dr("in2")) = 1 Then
                    pnl22.BackColor = Color.Black
                Else
                    pnl22.BackColor = Color.White
                End If

                If DBNULLtoZero(_dr("RollerStop1")) = 1 Then
                    Pipe1.MoveSpeed = 0
                Else
                    Pipe1.MoveSpeed = DBNULLtoZero(_dr("RollerUpDn1"))
                End If
                If DBNULLtoZero(_dr("RollerStop2")) = 1 Then
                    Pipe2.MoveSpeed = 0
                Else
                    Pipe2.MoveSpeed = DBNULLtoZero(_dr("RollerUpDn2"))
                End If

                Select Case DBNULLtoZero(_dr("moveStatus"))
                    Case 0
                        lblMove.Text = "静止"
                    Case 1
                        lblMove.Text = "慢进"
                    Case 2
                        lblMove.Text = "快进"
                    Case 3
                        lblMove.Text = "慢退"
                    Case 4
                        lblMove.Text = "快退"
                End Select

                setMDD(DBNULLtoZero(_dr("CurrentLoc")))
                lblActive.Text = DBNULLtoBlank(_dr("ActiveString"))
                lblBattery.Text = DBNULLtoZero(_dr("Battery")) & "%"
                If IIf(IsDBNull(_dr("controlMode")), False, _dr("controlMode")) = True Then
                    lblControlMode.Text = "远程控制"
                Else
                    lblControlMode.Text = "本地控制"
                End If

            Else
                lblCarName.BackColor = Color.Red
                lblCarName.ForeColor = Color.White
            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Private Sub setMDD(_mdd As Integer)
        Dim Y As Integer = 242
        'Dim Xplus As Integer = 90

        Dim Xplus As Integer = 100
        Dim Xbase As Integer = 176
        Dim Xbase2 As Integer = 68

        Select Case _mdd
            Case 103 '=1#-1FMS
                Me.Location = New Point(Xbase + Xplus * 0, Y)
            Case 101 '=1#-1FKX
                Me.Location = New Point(Xbase + Xplus * 1, Y)
            Case 3 '=1#-1GMS1-1
                Me.Location = New Point(Xbase + Xplus * 2, Y)
            Case 4 '=1#-1GKX-1
                Me.Location = New Point(Xbase + Xplus * 3, Y)
            Case 5 '=1#-1GMS1-2
                Me.Location = New Point(Xbase + Xplus * 4, Y)
            Case 109 '=1#-1GMS-3
                Me.Location = New Point(Xbase + Xplus * 5, Y)
            Case 9 '=1#-1GKX-3
                Me.Location = New Point(Xbase + Xplus * 6, Y)
                 '-----------------------------------------
            Case 12 '=1#-2FKS
                Me.Location = New Point(Xbase + Xplus * 7, Y)
            Case 11 '=1#-2FMX
                Me.Location = New Point(Xbase + Xplus * 8, Y)
            Case 13 '=1#-2GMX
                Me.Location = New Point(Xbase + Xplus * 9, Y)
            Case 14 '=1#-2GKS
                Me.Location = New Point(Xbase + Xplus * 10, Y)
                '========================================
            Case 102 '=2#-1FKX
                Me.Location = New Point(Xbase2 + Xplus * 0, Y)
            Case 101 '=2#-1FMS
                Me.Location = New Point(Xbase2 + Xplus * 1, Y)
            Case 103 '=2#-1GMS1-1
                Me.Location = New Point(Xbase2 + Xplus * 2, Y)
            Case 104 '=2#-1GKX-1
                Me.Location = New Point(Xbase2 + Xplus * 3, Y)
            Case 105 '=2#-1GMS1-2
                Me.Location = New Point(Xbase2 + Xplus * 4, Y)
            Case 110 '=2#-1GMS-3
                Me.Location = New Point(Xbase2 + Xplus * 5, Y)
            Case 109 '=2#-1GKX-3
                Me.Location = New Point(Xbase2 + Xplus * 6, Y)
                '-----------------------------------------
            Case 112 '=2#-2FKS
                Me.Location = New Point(Xbase2 + Xplus * 7, Y)
            Case 111 '=2#-2FMX
                Me.Location = New Point(Xbase2 + Xplus * 8, Y)
            Case 113 '=2#-2GMX
                Me.Location = New Point(Xbase2 + Xplus * 9, Y)
            Case 114 '=2#-2GKS
                Me.Location = New Point(Xbase2 + Xplus * 10, Y)
            Case 15 '=CDW
                If lblCarName.ToString.Contains("1") Then
                    Me.Location = New Point(12, 57)
                Else
                    Me.Location = New Point(1262, 57)
                End If
        End Select
    End Sub
End Class
